package main

import (
	"flag"
	"log"
	"strings"

	"github.com/optiopay/kafka"
)

var topic string
var partition int
var offset int

// // // // // // // // //
type StringArray []string

func (a *StringArray) Set(s string) error {
	*a = append(*a, s)
	return nil
}

func (a *StringArray) String() string {
	return strings.Join(*a, ",")
}

// // // // // // // // //

var kafkaAddrs StringArray

func init() {
	flag.StringVar(&topic, "topic", "", "your topic in kafka should be specified")
	flag.IntVar(&partition, "partition", 0, "which partition of this topic should be specified")
	flag.Var(&kafkaAddrs, "brokerlist", "your brokers host:port may be given multi-times")
	flag.IntVar(&offset, "offset", kafka.StartOffsetOldest, "consumer start from where")
	flag.Parse()
	if topic == "" {
		panic("please use --topic option")
	}
	if len(kafkaAddrs) == 0 {
		panic("please use --brokerlist")
	}
	showFlag()
}
func showFlag() {
	log.Println(topic, partition, kafkaAddrs)
}
